function departmentOver() {
    $('.department-menu').show();
    $('.department').css('background-color', '#ffac00');
    $('.department').css('color', 'white');
}
function departmentOut() {
    $('.department-menu').css('display', 'none');
    $('.department').css('background-color', 'transparent');
    $('.department').css('color', 'black');
}

var lastId = "animation";
function switch_department(id) {
    $("#" + lastId).removeClass("dActive");
    $("#" + id).addClass("dActive");
    $("." + lastId).css("display", "none");
    $("." + id).css("display", "block");
    lastId = id;
}
var n = 0;
$('#viewLogin').click(function () {
    if (n % 2 == 0) $('.loginList').css('display', 'block'), n++;
    else $('.loginList').css('display', 'none'), n++;

})

/**
 * 用于主页面向js 写入变量,不要问我为啥还定义了一个init方法，任性
 */

var Global = {
    "server": "",
    "init": function (server) {
        this.server = server;
    }
}

/**
 *登陆js
 */
function login() {
    $.ajax({
        url: Global.server + "/login",
        data: {'username': $('#username').val(), "password": $('#password').val()},
        method: "POST",
        success: function (data) {
            if (data == "登陆成功") {
                $('#tip').text(data);
                $('#tip').show();
                setTimeout("location.reload()", 1000);
            }
            $('#tip').text(data);
            $('#tip').show();
            setTimeout("$('#tip').hide()", 1000 * 3);

        }
    })
}

$('#password').keydown(function (event) {
    if (event.keyCode == 13)
        login();
})
$('.submit').click(function () {
    login();
})
